package com.ssm.zyn.service.impl;

import com.ssm.zyn.dao.RolelimitMapper;
import com.ssm.zyn.eo.RoleLimitEOpage;
import com.ssm.zyn.model.RoleLimit;
import com.ssm.zyn.service.RoleLimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 实现业务及流程接口当中的内容
 */
@Service
public class RoleLimitServiceImpl implements RoleLimitService {
    @Autowired
    private RolelimitMapper rolelimitMapper;
    @Override
    public int AddRoleLimit(RoleLimit roleLimit) {
        int returnInt = 0;


            //1.数据的添加
            int addRoleInt = rolelimitMapper.insertRoleLimit(roleLimit);
            //2.返回值的设置
            returnInt = addRoleInt;


        return returnInt;
    }

    @Override
    public int UpdateRoleLimit(RoleLimit roleLimit) {
        int isUpdate = 0;
        /*1.没有相关业务流程的判断*/
        try {
            isUpdate = rolelimitMapper.updateRoleLimit(roleLimit);
        } catch (Exception e) {
            isUpdate = -1;
            //打印更新时报错的情况
            System.out.println("更新角色信息时执行SQL报错的原因为"+e.getMessage());
        }
        return isUpdate;
    }

    @Override
    public int DeleteRoleLimit(int rlid) {
        int delRoleLimit=0;
        try{
            delRoleLimit=rolelimitMapper.delRoleLimit(rlid);
        }catch (Exception e){
            delRoleLimit=-1;
            System.out.println("删除班级信息时执行SQL报错，信息为"+e.getMessage());
        }
        return delRoleLimit;
    }

    @Override
    public List<RoleLimitEOpage> getWhereAll(RoleLimitEOpage roleLimitEOpage) {
        List<RoleLimitEOpage> listRoleLimit= rolelimitMapper.getWhereAll(roleLimitEOpage);
        return listRoleLimit;
    }
}
